<?php
require_once	'Zend/Controller/Plugin/Abstract.php';
require_once 'Zend/Session/Namespace.php';
class googleproduct extends Zend_Controller_Plugin_Abstract {
	var $xml;
	static $excel;
	static $csv;
	var $site;
	
	public function __construct($site){
		$this->site="http://".$site."/";
		$this->xml="<?xml version='1.0' encoding='utf-8' ?>\n";
		$this->xml.="\t<rss version='2.0' xmlns:g='http://base.google.com/ns/1.0'>\n";
		$this->xml.="\t<channel>\n";
		$this->xml.="\t<title>plima products</title>\n";
		$this->xml.="\t<link>".$this->site."</link>\n";
		$this->xml.="\t<description>A description of your content</description>\n";
	}
	
	public function toXml($products){
		for($i=0;$i<sizeof($products);$i++){
			$this->xml.=$this->xml_item($products[$i]['set']);
			}
		$this->xml.="\t</channel>\n";
		$this->xml.="\t</rss>";
		return $this->xml;
	}
	
	private function xml_item($info){
		$temp="\t<item>\n";
		$temp.="\t<id>".$info['product_id']."</title>\n";
		$temp.="\t<title>".str_replace('&','',$info['name'])."</sku>\n";
		$temp.="\t<description>".$info['short_description']."</description>\n";
		$temp.="\t<g:link>".$this->site.$info['url_key']."</g:link>\n";
		$temp.="\t<g:image_link>".$this->site."media/catalog/product".$info[0]."</g:image_link>\n";
		$temp.="\t<g:price>".$info['special_price']."</g:price>\n";
		$temp.="\t<g:made in>"."china"."</g:made in>\n";
		$temp.="\t<g:condition>".""."</g:condition>\n";
		$temp.="\t</item>\n";
		return $temp;
		}	
}
?>